/**
 *
 *  Project      :  UVa's acm
 *  Project site :  code.google.com/p/uvaacm/
 *  Author       :  Ives Liao
 *  E-Mail       :  iveslazycat at gmail.com
 *  Date         :  2011/11/17
 *  Website      :  iveslazycat.pixnet.net
 *  
 */
#ifdef ONLINE_JUDGE /* If compiler is UVa's online judge */
    #include<stdio.h> /*Include standard header foe UVa's compiler */
    #include<stdlib.h>
    #include<math.h>
    #define INPUT stdin /* Define the input is from standard input */
#else
    #include"header.h" /* Include my own header */
    #define INPUT fptIn /* Define the input is from input file */
#endif
/*---------- Do sub function declare below here \/----------*/
int hex2dec(int hex);
int numOfOneInBinFromDec(int Dec);
/*---------- Do sub function declare above here /\----------*/
#ifdef ONLINE_JUDGE
	int main() {/* main() for UVa's online judge */
#else
    int acm_10019() {/* function name for my own */
        printf("--acm_10019 begin here--\n");/* Print begining of problem */
        FILE *fptIn = fopen("Resource/acm_10019.txt","r");/* Open input file to test */
        if ( fptIn == NULL )/* Distinguish the fptInIn file is load success. */
        {
            printf("File acm_10019.txt load fail.\n");/* Telling user file loading failed. */
            printf("Program will exit.\n");/* Telling user function gonna end. */
            return EXIT_FAILURE;/* Return to problem selector(main) */
        }/*End of file check*/
#endif
/*---------- Do primary statment below here \/----------*/
    int runTimes = 0, num=0;
    for( fscanf(INPUT," %d",&runTimes); runTimes > 0 ; runTimes = runTimes - 1 ){
        fscanf(INPUT," %d",&num);
        printf("%d %d\n",numOfOneInBinFromDec(num),numOfOneInBinFromDec(hex2dec(num)));
    }

/*---------- Do primary statment above here /\----------*/
    #ifndef ONLINE_JUDGE/* If compiler isn't UVa's online judge */
        printf("--acm_10019 end here--\n");/* Print end of problem */
        fclose(fptIn);/* Close file */
    #endif
    return 0;
}/*End of main() function*/
/*---------- Do sub function statment below here /\----------*/

    int hex2dec(int hex){
        int dec = 0, i = 0 ;
        while(hex > 0){
            dec = dec + (hex % 10)*pow(16,i);
            hex = hex / 10 ;
            i = i + 1;
        }
        return dec;
    }
    int numOfOneInBinFromDec(int dec){/*Success*/
        int numOfOne = 0 ;
        while(dec > 0){
            switch( dec % 16 ){
                case 1:
                case 2:
                case 4:
                case 8:
                    numOfOne = numOfOne + 1;
                    break;
                case 3:
                case 5:
                case 6:
                case 9:
                case 10:
                case 12:
                    numOfOne = numOfOne + 2;
                    break;
                case 7:
                case 11:
                case 13:
                case 14:
                    numOfOne = numOfOne + 3;
                    break;
                case 15:
                    numOfOne = numOfOne + 4;
                    break;
            }
            dec = dec / 16;
        }
        return numOfOne;
    }

/*---------- Do sub function statment above here \/----------*/
